<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.kma.ncpractice2013.dao.UserDAO" %>
<%@ page import="com.kma.ncpractice2013.model.User" %>
<%@ page import="com.kma.ncpractice2013.dao.UserGroupDAO" %>
<%@ page import="com.kma.ncpractice2013.model.UserGroup" %>
<%@ page import="com.kma.ncpractice2013.model.Commission" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>VIP-status</title>
<link rel="stylesheet" href="vipstatus.css" />
<link rel="stylesheet" href="/paging.css" />
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/start/jquery-ui.css" />
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="vipstatus_paging.js"></script>
<script>
	var v;
	var anyId = 4;
	var VIPId = <%= User.Group.VIPCustomer.getValue() %>;
	var ordinaryId = <%= User.Group.ordinaryCustomer.getValue() %>;
</script>
<script type="text/javascript" src="vipstatus.js"></script>

<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
</head>

<body>

<div id="header-wrapper">
<div id="header" class="container">
	<div id="logo">
    	<h1><a href="#">Accommodation</a></h1>
    </div>
    <%

        String b = (String)session.getAttribute("auth");
        User user = (User)session.getAttribute("user");
            if(b!=null && b.equals("true"))
            {

                out.print("<div id=\"auth\"><form>" +
				"Welcome, "+ user.getName()+ " | " +
                                  "<a href=\"logout.jsp\">Log out</a>" +
						  "</form></div>\n");
            }

        else
        out.print("<div id=\"auth\">" +
                                  "<form method=\"post\" action=\"Auth\">"+
                          "        <input size=\"20\" type=\"text\" placeholder=\"e-mail\" name=\"username\">\n" +

                          "        <input size=\"15\" type=\"password\" placeholder=\"password\" name=\"password\">\n" +
                          "        <input type=\"submit\" value=\"Log in\">\n" +
                          "        <a id=\"regist\" href=\"register.jsp\">Register</a>\n" +
                                "</form>"+
						  "        <br clear=\"all\"><a id=\"reset_pass\" href=\"resetPassword.jsp\">Forgot your password?</a>\n" +
                          "    </div>\n");
    %>


</div>
</div>

<div id="menu-wrapper">
<div id="menu" class="container">
<%

	if(b!=null && b.equals("true") && user != null)
	{
		User.AccessLevel accessLevel = user.getAccessLevelId();
		if (accessLevel == User.AccessLevel.administrator)
		{
			out.print("<ul>\n"+
			 "<li class=\"active\"><a href=\"#\">Main page</a></li>\n" + 
			 "<li><a href=\"user/userProfile.jsp\">Profile</a></li>\n" +
			 "<li><a href=\"admin/dashboard.jsp\">Admin's dashboard</a></li>\n" +
				"</ul>\n");
		}
		else if (accessLevel == User.AccessLevel.manager)
		{
			out.print("<ul>\n"+
			 "<li><a href=\"/main_page.jsp\">Main page</a></li>\n" + 
			 "<li><a href=\"/user/userProfile.jsp\">Profile</a></li>\n" +
			 "<li><a href=\"/manager/discounts.jsp\">Comissions and discounts</a></li>\n" +
			 "<li><a href=\"/manager/promocodes.jsp\">Promo-codes</a></li>\n" +
			 "<li class=\"active\"><a href=\"/manager/vipstatus.jsp\">VIP-status</a></li>\n" +
			 "<li><a href=\"/manager/reports.jsp\">Reports</a></li>\n" +
				"</ul>\n");
		}
	}
%>
</div>
</div>

<div id="content-wrapper">
<div id="content" class="container">

    <div id="search-part">
        <div class="left-column"><header>Search users</header></div>
        <div id="right-preloader"><img src="/482.GIF" /></div>
        <br clear="all">
        <table>
            <tr><td>Login: </td><td class="droite"><input type="text" id="login"></td></tr>
            <tr><td>Name: </td><td class="droite"><input type="text" id="name"></td></tr>
            <tr><td>Surname: </td><td class="droite"><input type="text" id="surname"></td></tr> 
            <tr><td>User status: </td>
            <td class="droite"><select id="group">
              <option id="option1">Any registered user</option>
              <option id="option2">Ordinary user</option>
              <option id="option3">VIP user</option>
            </select></td>
            </tr>   	
            <tr><td><a href="javascript:performQuery()" class="button" id="bsearch">Search!</a></td></tr>
        </table> 
    </div>   
    
    <div id="results">
    	<header>Search results: <span type="text" id="results-count"></span></header>
        <table id="result-table">
        </table>
        <div id="pageNavPosition" class="pageNavigation"></div>
        <input id="revoke-vip" style="float:right; margin:10px; display:none" value="Revoke VIP-status" type="button" onClick="revokeStatus()" >
        <input id="grant-vip" style="float:right; margin:10px; display:none" value="Grant VIP-status" type="button" onClick="grantStatus()" >
    </div>
    
</div>
</div>

<div id="copyright-wrapper">
<div id="copyright" class="container">
Copyright (c) 2013. All rights reserved.
</div>
</div>

</body>

</html>
